﻿@using SelfMadeMillionaire.Core
@using SelfMadeMillionaire.Web.Infrastructure
@model SelfMadeMillionaire.Web.Infrastructure.ViewModels.Newsletters.NewsletterPublicEditViewModel

@{
	ViewBag.Title = "Details";

    string filePath = FileLink.GetSaveFilePath(Model.Item.PdfFileName);
    string fileLink = FileLink.GetAbsoluteLinkOnFile(Model.Item.PdfFileName);
    bool isFileExists = File.Exists(filePath);
}

<div class="row">
    @Html.HiddenFor(m => m.Item.ID, new { id = "NewsletterId" })    
	<div class="col-sm-12 col-md-12 col-lg-12">

		<!--left content block-->
		<div class="left_col_block">
			<div class="content_block_title">
				<h5>@Model.Item.Date.ToString("MMMM dd, yyyy") @Model.Item.IssueType.Title</h5>
				<div class="title_bottom_arrow">
					<img src="@Url.Content("~/Content/images/down_arrow.png")" alt="" />
				</div>
			</div>

			@if (!string.IsNullOrWhiteSpace(Model.Item.PdfFileName))
			{
				<div class="options_container">
					<h4 class="options_title">@Model.Item.Title
                        @if ((Request.IsAuthenticated) && (isFileExists))
                        {
						    <a class="right_pdf_icon" href="@FileLink.GetAbsoluteLinkOnFile(@Model.Item.PdfFileName)">
							<img src="@Url.Content("~/Content/images/pdf_icon.png")" alt="PDF download" title="PDF download" /></a>
                        }
					</h4>
                    @if (isFileExists)
                    {
					    <iframe src="@Url.Content("~/Newsletters/NewsletterFile/" + Model.Item.ID)" width="100%" height="600"></iframe>
                    }
				</div>
			}

		</div>
		<!--end left content block-->

	</div>

</div>

<div class="row">
    <div class="col-sm-6 col-md-6 col-lg-6">
        <div class="left_col_block">
			<div class="content_block_title">
				<h5 style="height:35px;vertical-align:middle;padding-top:10px">More @Model.Item.IssueType.Title Issues</h5>
				<div class="title_bottom_arrow">
					<img src="@Url.Content("~/Content/images/down_arrow.png")" alt="" />
				</div>
			</div>

            <div class="recent_issue_block options_container">
                <ul>
		        @foreach (var item in Model.OtherIssue)
		        {
			        <li><a href="@Url.Action("Details", "Newsletters", new { id = item.ID })">@item.Title</a></li>
		        }
	            </ul>
            </div>
        </div>
    </div>
    <div class="col-sm-6 col-md-6 col-lg-6">
        <div class="left_col_block" id="divBySymbol">
			
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        LoadBySymbol('');
    });

    function LoadBySymbol(symbol) {

        $.get("@Url.Action("BySymbol")",
            {
                id: $("#NewsletterId").val(),
                symbol: symbol
            },
            function (result) {
                $("#divBySymbol").html(result);
            });
    }


</script>


